package test_activiti;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.activiti.engine.form.FormProperty;
import org.activiti.engine.form.TaskFormData;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.activiti.engine.test.ActivitiTestCase;
import org.activiti.engine.test.Deployment;

public class 测试读取表单数据 extends ActivitiTestCase {

	//可以用逗号分隔开要部署的bpmn
	@Deployment(resources = {"bgApp.bpmn"})
	public void testMe() {
		    ProcessInstance pi = runtimeService.startProcessInstanceByKey("bgApp");
		    String piId = pi.getId();

		    Task task = taskService.createTaskQuery().taskAssignee("yw").includeTaskLocalVariables().singleResult();
		    System.out.println("formkey = "+task.getFormKey());
		    Map<String,Object> vmap = new HashMap<String,Object>();
		    vmap.put("sp_yw",1);

		    TaskFormData tfd = formService.getTaskFormData(task.getId());
		    List<FormProperty> list= tfd.getFormProperties();
		    System.out.println("第一个表单属性:"+list.get(0).getName()+"="+list.get(0).getValue());


		    ActivitiUtils.printTaskLocalVari(task);

		    ActivitiUtils.printProcInstHistory(historicDataService,runtimeService,piId);

		    taskService.complete(task.getId(),vmap); //流程挂起后，不可complete.会触发异常



	}
}
